﻿var self = this;
var mySwiper;
var getPathFloor = [];
var saveFloor = [];
var saveCompareGet = [];
var getToggleFloor = [];
var nowPositionpoint = 'POINT-2018052-13:28:51:231-277'
var isPosition = true;
var isPathFinding = false;
var realDiss = ''
var fIndex;
var lIndex;
var object = {
	startP: '',
	endP: '',
	startPP: '',
	endPP: '',
	isXunlu: false,
	isStart: false,
	isEnd: false,
	xlId: {},
	searchList: '',
	flooridFloors: {},
	isBlock: true,
	zoomLevel: 20,
	flagAudio: true,
	floorid: GetQueryString('floorid') ? GetQueryString('floorid') : "FFB6CB4B-AB5B-425A-BA96-51FB215FEEE4",
	mark: GetQueryString('mark'),
	mac: GetQueryString('mac'),
	ip: GetQueryString('ip'),
	flag: true,
	floorserv: '',
	orderFloors: {},
	flooridOrder: {},
	order: 22, 
	flags: true,
	ispoint: true,
	isInitOrder: true,
	pointmove: JSON.parse(GetQueryString('pointmove')),
	location: false,
	timer: '', 
	pathfinding: JSON.parse(GetQueryString('pathfinding')),
	shopList: [],
	moFloorid: {
		start: '',
		end: '',
		startArea: '',
		endArea: ''
	},
	navigationInterval: '',
	areaID: "",
	shopID: JSON.parse(GetQueryString('shopID')),
	getServeData: function (data, fn) { 
		$.ajax({
			type: "GET",
			url: object.url,
			data: data,
			dataType: "JSONP",
			success: function (s) {
				fn(s);
			}
		});
	}, 
// url:"./php/getdata.php", 
 url: "https://map.ckiosk.cn/webAPI/ClientService.asmx/Command?callback", 
	audioEnd: true,
	command: '',
	param: '',
	feature: '',
	isShare: false,
	
}
var config = {
	flagMark: false,
	Project: 'A946DBEE-51C9-4A97-A0BB-42EF31B3E029', 
	ReacordValue: 'A946DBEE-51C9-4A97-A0BB-42EF31B3E029', 
	floorNumber: ''
}

$(document).ready(function () {
	$.ajax({
		type: 'GET',
		url: 'https://service.chaunve.com/RecordWebService.asmx/Record?Project=' + config.Project + '&Type=CLOUDMAP&ReacordValue=' + config.ReacordValue + '&AccessFrom=',
		success: function (s) {
			console.log(s)
		}
	})

	if (object.pathfinding) {
		object.floorid = object.pathfinding.startFloorid
	}
	
	$('.compass').on('click', function () {
		self.map.setPolarAngle(25);
		self.map.setAzimuthalAngle(90);
		$(this).css({
			'transform': 'rotate(90deg)'
		})
	});
	if (object.shopID) {
		for (var i = 0; i < L.length; i++) {
			if (object.shopID.floorid == L[i].name) {
				object.order = L.length + 1 - Number(L[i + 1].order)
				object.floorid = L[i].floorID
				break;
			}
		}
	}
	init(object.floorid)
	spanBtn()
	historyBtn()
});
window.alert = function (name) {
	var iframe = document.createElement("IFRAME");
	iframe.style.display = "none";
	iframe.setAttribute("src", 'data:text/plain,');
	document.documentElement.appendChild(iframe);
	window.frames[0].window.alert(name);
	iframe.parentNode.removeChild(iframe);
};

function reverse() {
	var middleID, middleVal, middlePathID;
	
	reverseInside()
	if (isPathFinding) {
		middleID = object.moFloorid.start;
		object.moFloorid.start = object.moFloorid.end;
		object.moFloorid.end = middleID;
		middlePathID = object.pathfinding.sId;
		object.pathfinding.sId = object.pathfinding.eId;
		object.pathfinding.eId = middlePathID;
		middleVal = $('#startPoint').val();
		$('#startPoint').val($('#endPoint').val());
		$('#endPoint').val(middleVal);
		object.startP = self.map.startNode.pointID = object.pathfinding.sId;
		object.endP = self.map.endNode.pointID = object.pathfinding.eId;
		self.map.addMarkToPoint(object.pathfinding.sId, 'start')
		self.map.addMarkToPoint(object.pathfinding.eId, 'end')
	}else if(nowPositionpoint){
		middleID = nowPositionpoint;
		nowPositionpoint = object.xlId.endId;
		object.xlId.endId = middleID;
		middleVal = $('#startPoint').val();
		$('#startPoint').val($('#endPoint').val());
		$('#endPoint').val(middleVal);
		object.startP = self.map.setStartArea(nowPositionpoint, true);
		object.endP = self.map.setEndArea(object.xlId.endId, true);
	} else {
		middleID = object.xlId.startId;
		object.xlId.startId = object.xlId.endId;
		object.xlId.endId = middleID;
		middleVal = $('#startPoint').val();
		$('#startPoint').val($('#endPoint').val());
		$('#endPoint').val(middleVal);
		object.startP = self.map.setStartArea(object.xlId.startId, true);
		object.endP = self.map.setEndArea(object.xlId.endId, true);
		$('.setPoint1').css('display', 'block');
		if (object.startP && object.endP) {
			$('.floorToggle,.floorToggleMinUl,.scale,.floorToggleUlBox').css('bottom', '2rem');
			$('.tishi').html('点击开始导航');
			$('.go').removeAttr("disabled").css('backgroundColor', '#a6937c');
		}
	}
	
	pathGo();
}


function init() {
	GIM.SHOW_SPRITE_LENGTH = 2500 * 6;
	GIM.SHOW_Facility_LENGTH = 3000 * 2;
	GIM.PATH_COLOR = '#00b81f';
	// GIM.REMOTE_SERVER = './php/getdata.php';
	GIM.DEBUG_MODE = false; 
	var container = document.getElementById('mapContainer')
	container.style.cssText = "width:" + (container.clientWidth / 1) + "px;height:" + (container.clientHeight / 1) + "px;overflow: hidden;position: absolute;text-align:right";
	var params = {
		initCompleted: initCompelte,
		onSelected: onSelected,
		container: container,
		themeID: "1003",
		accessToken: "86E81446-7C98-432F",
		backgroundColor: '#f2f2f2',
		projectID: 'A946DBEE-51C9-4A97-A0BB-42EF31B3E029',
		optFloorID:"FFB6CB4B-AB5B-425A-BA96-51FB215FEEE4",
		initFloorID: object.floorid,
		cloudID: '0C5F2CCF-F952-41F1-BB4D-AEF36A051606',
		showLabelType: "Name",
		labelScale: 1.4
	}
	self.map = new GIM.Map3D(params);
	self.map.zoomLevel(object.zoomLevel);
	self.map.maxCameraRadius = 18000;
		self.map.setPolarAngle(0);
	self.map.setAzimuthalAngle(95);
	self.map.move2Point({
		x: 200,
		y: -400
	});
	self.map.showCompass(false);
	self.map.regCompassChange(function (angel) {
		$('.compass').css({
			'transform': 'rotate(' + angel + 'deg)'
		})
	})
}

function doNextThing() {
	if (object.mac || object.ip) {
		object.isShop = false;
		if (!GetQueryString('shopID') || object.pathfinding) {
			setTimeout(function () {
				$('.waiting').html('正在定位中，请稍等...');
			}, 2000);
			getWifi();
		} else {
			if (object.pathfinding) {
				return
			} else {
				$('.waiting').html('地图加载完成')
				setTimeout(function () {
					$('.waiting').fadeOut(3000)
				}, 2000);
			}
		}
	} else {
		if (object.pathfinding) {
			return
		} else {
			$('.waiting').html('地图加载完成')
			setTimeout(function () {
				$('.waiting').fadeOut(3000)
			}, 2000);
		}

	}

}

function initCompelte($floorData, areaData, list) {
	self.map.pathThickness = 33;
	self.map.pathColor = 0x008000;
	self.map.pathGap = 8;
	nowFloorToggleNo = "25F"
	self.map.cameraRadius = 60000;
	config.floorNumber = $floorData.length;
	object.floorData = $floorData;
	object.floorData = object.floorData.sort(function (a, b) {
		return a.order - b.order;
	});
	object.floorData.forEach(function (t) {
		object.flooridFloors[t.floorID] = t.name;
		object.orderFloors[t.name] = t.floorID;
		object.flooridOrder[t.floorID] = t.order;
	});
	object.feature = areaData
	console.log(object.feature)
	areaData.forEach(function (t) {
		object.shopList = object.shopList.concat(t.Area)
	});
	setTimeout(function(){
		self.map.addMarkToPoint(nowPositionpoint, 'start')
	},500)
 
	object.startP = self.map.startNode.pointID = nowPositionpoint;
	object.searchList = list;
	$('.waiting').css({
		"display": 'block'
	}).stop(false, true).html('地图加载完成');
	setTimeout(function () {
		$('.waiting').fadeOut();
	}, 3000);
	if (object.mark) {
		setTimeout(function () {
			self.map.selectUint3DByAreaId(object.mark);
		}, 2000);
		object.order = config.floorNumber - Number(object.flooridOrder[GetQueryString('floorid')])
		object.shopID = null;
		object.isSwiper = true;
		mySwiper.destroy(true);
		mySwiper = myswiper();
		mySwiper.init();
		$('#loadings').css('display', 'none');
	}
	if (object.shopID) {
		self.map.focusToShopByNo(object.shopID, 5, 15);
		$('.waiting').css({
			"display": 'block'
		}).stop(false, true).html('地图加载完成');
		setTimeout(function () {
			$('.waiting').fadeOut(4000);
		}, 3000);
		object.shopID = null;
		object.isSwiper = true;
		$('#loadings').css('display', 'none');
	} else if (object.pathfinding) {
		isPathFinding = true;
		$(".spinner div").css("width", ".2rem")
		
		$('.waiting').css({
			"display": 'block'
		}).stop(false, true).html('路径规划中,请稍后...');
		self.map.regPathDownloaded(function () {
			object.startP = self.map.startNode.pointID = object.pathfinding.sId;
			object.endP = self.map.endNode.pointID = object.pathfinding.eId;
			object.order = object.floorData.length - object.flooridOrder[object.pathfinding.sFid]
			object.moFloorid.start = object.pathfinding.sFid
			
			$('.looking').stop(false, true).css({
				'display': 'none'
			})
			self.map.regNavigationPause(function () { 
				$(".floorToggleMinUl li button").removeAttr("disabled");
				
				$(".mo_center").html("继续导航")
				$('.floorToggle').show()
				object.isPause = true;
				isFloorToggleCounter = true;
			})
			self.map.searchPath(function (msg) {
				if (msg.type == 'done') {
				
					self.map.zoomLevel(12);
					
					self.map.setPolarAngle(object.pathfinding.X)
					self.map.setAzimuthalAngle(object.pathfinding.Z)
					$('#loadings').css('display', 'none');
					$('.waiting').stop(false, true).css({
						"display": 'block'
					}).html('路径规划成功');
					object.ispoint = true;
					setTimeout(function() {
						$(".operation").show()
						$('.gSearch').hide()
						$('.compass').css({
							'top': '1.68rem'
						})
						self.map.addMarkToPoint(object.pathfinding.sId, 'start')
						self.map.addMarkToPoint(object.pathfinding.eId, 'end')
					}, 0)
				} else {
					$('#loadings').css('display', 'none');
					alert('寻路失败');
					return;
				}
				setTimeout(function () {
					$('.waiting').fadeOut(4000);
				}, 3000);
				$('#startPoint').val('我的位置');
				object.shopList.forEach(function(t) {
					if (t.PointID == object.pathfinding.eId) {
						$('#endPoint').val(object.flooridFloors[object.pathfinding.eFid] + '  ' + (t.shopName ? t.shopName : t.Name))
					}
				})
			})
			object.moFloorid.end = object.pathfinding.eFid
			
			pathGo()
		});
		object.isSwiper = true;
	} else {
		setTimeout(function () {
			$('#loadings').css('display', 'none');
			object.isSwiper = true;
		}, 10);
	}

	createWXConfig(postData);
	if (object.mac) {
		document.addEventListener("visibilitychange", handleVisibilityChange, false);
	}
	FloorDetection()
}


function onSelected(data) {
	object.flag = true;
	object.mark = data.areaID;
	object.isShare = true;
	self.map.setPolarAngle(15);
	$('#text').val(data.EnName)
	self.map.regNavigationPause(function () { 
		$(".mo_center").html("继续导航")
		$(".scale").show()
		isPause = true;
	})
	self.map.toggleSimulate()
	$('.mo_daohang,.mo_tishi').slideUp('slow');
	$('.pointName').html(data.EnName ? data.EnName : data.name);
	$('.pointFloor').html(object.flooridFloors[data.floorID]);
	nowFloorToggleNo = object.flooridFloors[data.floorID]
	FloorDetection()
	setStart = function () {
		$('.operation').css('display', 'block');
		$('.compass').css({
			'top': '2.05rem'
		})
		$('#startPoint').val(object.flooridFloors[data.floorID] + ' ' + ' ' + ' ' + (data.EnName ? data.EnName : data.name));
		object.startPP = object.flooridFloors[data.floorID];
		object.areaID = data.areaID;
		object.xlId.startId = data.areaID;
		object.moFloorid.start = data.floorID;
		object.moFloorid.startArea = data.EnName;
		object.startP = self.map.setStartArea(data.areaID, true);
		object.ispoint = false;
		object.isStart = false
		if (object.endP == '' || object.endP == null) {
			$('.tishi').html('请设置终点');

			$('.go,.mogo').attr("disabled", 'disabled').css('backgroundColor', '#999');
		} else {
			$('.tishi').html('点击开始导航');
			$('.mogo').removeAttr("disabled").css('backgroundColor', '#a6937c');
			$('.go').removeAttr("disabled").css('backgroundColor', '#999');
		}
		$('.operation').css('display') == 'block' ? $('.gSearch').hide() : $('.gSearch').show()
		$('.operation').css('display') == 'block' ? $('.nav_qyfg').hide() : $('.nav_qyfg').show()
		pathGo()


	}
	setEnd = function () {
		$(".operation").css('display', 'block')
		object.xlId.endId = data.areaID;
		object.moFloorid.end = data.floorID
		$('#endPoint').val(object.flooridFloors[data.floorID] + ' ' + ' ' + ' ' + (data.EnName ? data.EnName : data.name));
		object.moFloorid.endArea = data.EnName
		object.endPP = object.flooridFloors[data.floorID]
		$('.compass').css({
			'top': '2.05rem'
		})
		$('.tishi').html('点击开始导航');
		object.isEnd = false
		object.endP = self.map.setEndArea(data.areaID, true);
		if (object.startP == '' || object.startP == null) {
			$('.tishi').html('请设置起点');
			$('.go,.mogo').attr("disabled", 'disabled').css('backgroundColor', '#999');
		} else {
			$('.tishi').html('点击开始导航');
			$('.mogo').attr("disabled", false).css('backgroundColor', '#a6937c');
			$('.go').attr("disabled", false).css('backgroundColor', '#999');
		}
		$('.operation').css('display') == 'block' ? $('.gSearch').hide() : $('.gSearch').show()

		pathGo()

	}
};
function searchKeys(needle, haystack) {
	for (i in haystack) {
		if (haystack[i] == needle) {
			if (i.length < 2) {
				fIndex = i
				return fIndex
			} else if (i.length > 1) {
				fIndex = i[0]
				lIndex = i[1]
				return lIndex
			}
		}
	}
}
function goback() {
	object.endP = '';
	object.startPP = '';
	object.endPP = '';
	object.isXunlu = false
	self.map.areaClickEmbed = true;
	self.map.zoomLevel(object.jibie);
	self.map.clearPath(true);
	self.map.cleanSelectUnit3D()
	goBackInside()
	isPathFinding = false;
	isPosition = true;
	$('.operation, #loadings,.nav_qj,.nav_zz').css('display', 'none');
	$('.compass').css('top', '1.8rem');
	$(".floorToggle").show()
	$('.floorToggleUl,.shares').hide()
	$(".floorToggleUl li").show()
	$(".goToPath").show()
	$('.nav_qyfg').show()
	$('.bg_gSearch').show()
	$('#endPoint,#startPoint,#text').val('');
	$('.gSearch,.changeF').css('display', 'block');

	//if(dataO!==""&&dataO!==undefined){
	//	self.map.showFloors([dataO])
	//}else if(object.moFloorid.end){
	//	self.map.showFloors([object.moFloorid.end])
	//}else{
	//	self.map.showFloors([object.floorid])
	//}
	//object.order = object.floorData.length - object.flooridOrder[object.flooridFloors[object.moFloorid.start]]
	//FloorDetection()
	self.map.setPolarAngle(0);
	self.map.setAzimuthalAngle(95);
	self.map.move2Point({
		x: 200,
		y: -400
	});
	
}

function share(number) {
	if (object.isShare) {
		$('.goToPath').hide(500)
		$(".followMe").slideUp(500);
		$(".scale,.floorToggleBox,.floorToggleMinUl").css("bottom", "1.9rem")
		if (number == 1) {
			$('.shares').slideDown('slow')
		} else if (number == 2 && isPathGo == true) {
			$(".scale,.floorToggleBox,.floorToggleMinUl").css("bottom", ".8rem")
			$('.shares').slideUp(500)
			$(".followMe").slideDown(500)
			$(".scale,.floorToggleBox,.floorToggleMinUl").css("bottom", "1.3rem")
		} else if (isPathGo == true) {
			$(".scale,.floorToggleBox,.floorToggleMinUl").css("bottom", "1.2rem")
		} else if (number == 2) {
			$(".scale,.floorToggleBox,.floorToggleMinUl").css("bottom", ".8rem")
			$('.goToPath').show(500)
			$('.shares').slideUp(500)
		} else {
			$('.goToPath').show()
			$('.shares').slideUp('slow')
		}
	} else {
		return
	}
}



function noShow() {
	$('.share_shade').css('display', 'none')
}
function biger() {
	object.zoomLevel -= 3
	if (object.zoomLevel < 0) {
		object.zoomLevel = 0;
	}
	self.map.zoomLevel(object.zoomLevel);
}
function smaller() {
	object.zoomLevel += 3
	if (object.zoomLevel > 20) {
		object.zoomLevel = 20
	}
	self.map.zoomLevel(object.zoomLevel);
}

function showMark() {
	$('.waiting').css({
		'display': 'block'
	}).html('正在定位中，请稍等...')
	object.flags = true
	object.isInitOrder = false
	if (object.mac || object.ip) {
		self.map.showLocation()
		$('.mark').addClass('marking')
		object.timer = setInterval(getLocation, 2000);
	} else {
		$('.mark').removeClass('marking')
		$('.waiting').html('WIFI未打开,无法定位')
		setTimeout(function () {
			$('.waiting').fadeOut(3000)
		}, 3000)
	}
}
function mapToggle() {
	var value = $('.map_three').text()
	if (value == '3D') {
		self.map.setPolarAngle(60)
		$('.map_three').text('2D')
	} else {
		self.map.setPolarAngle(0)
		$('.map_three').text('3D')
	}

}

function audioAutoPlay(id, otext, ospd) {
	var audio = document.getElementById(id)
	if (object.audioEnd) {
		object.audioEnd = false
		$.get("https://map.ckiosk.cn/ShaneService/TTSWebService.asmx/BaiduTTS?", {
				"text": otext,
				"spd": ospd
			},
			function (data) {
				$(".mo_yuyin").attr("src", data);
			})
		play = function () {
			audio.play();
			document.removeEventListener("touchstart", play, false);
		};
		audio.play();
		document.addEventListener("WeixinJSBridgeReady", function () {
			play();
		}, false);
		document.addEventListener('YixinJSBridgeReady', function () {
			play();
		}, false);
		$(".mo_yuyin").attr("src", "");
	}
	if (audio.ended) {
		object.audioEnd = true;
	}
}


function go() {

}
function mogo() {
	if (object.startP == object.endP) {
		alert("起始点相同,请重新设置")
		return
	}
	audioAutoPlay("mo_yuyin", "开始导航", "5");

	var i = 1;
	object.timers = setInterval(function () {
		i = i + 1;
	}, 1000)
	$('.bg_gSearch').hide()
	$('.nav_qyfg').hide()

	$(".floorToggleUl").hide();
	$(".message").hide();
	$(".mark").hide();
	$(".scale").hide();
	$(".floorToggle,.floorToggleUl").css("bottom", "1.5rem")
	$('.operation').slideUp('fast');
	$('.mo_daohang,.mo_tishi').slideDown('fast');
	$('.looking,.changeF,.gSearch').hide()
	$(".compass").css("top", "2.05rem")
	$('.mo_text').html('请沿当前路线行走');
	$('#endPoint').val()
	$('.mo_footerS span').html('' + $('#startPoint').val() + '')
	$('.mo_footerE span').html('' + $('#endPoint').val() + '')
	$('.mo_end_q').html('起点 : ' + $('#startPoint').val() + '')
	$('.mo_end_z').html('目标 : ' + $('#endPoint').val() + '')
	self.map.zoomLevel(1)
	self.map.setPolarAngle(0);
	self.map.simulate()
	self.map.regNavigationWalk(function (walkDetail) {
		self.map.areaClickEmbed = false;
		nowFloorId = walkDetail.floorID;
		$(".mo_distance").html(walkDetail)
		if (!walkDetail.nextFloorName) {
			if (walkDetail.turn == 'Right') {
				$('.mo_text').html(+Math.ceil(walkDetail.dis / 50) + '米后 右转')
				if (Math.ceil(walkDetail.dis / 50) > 0) {
					$('.mo_pic').css({
						'background': 'url(./images/youzhuan.png) center center no-repeat',
						'backgroundSize': 'contain'
					})
				}
				if (walkDetail.dis > 0 && walkDetail.dis < 150) {
					$('.mo_text').html('右转')
					if (object.flagAudio) {
						audioAutoPlay("mo_yuyin", "前方右转", "5")
					}
				}
			} else if (walkDetail.turn == 'Left') {
				$('.mo_text').html(+Math.ceil(walkDetail.dis / 50) + '米后 左转')
				if (Math.ceil(walkDetail.dis / 50) > 0) {
					$('.mo_pic').css({
						'background': 'url("./images/zuozhuan.png") center center no-repeat',
						'backgroundSize': 'contain'
					})
				}

				if (walkDetail.dis > 0 && walkDetail.dis < 150) {
					$('.mo_text').html('左转')
					if (object.flagAudio) {
						audioAutoPlay("mo_yuyin", "前方左转", "5")
					}
				}
			} else if (walkDetail.turn == 'LeftFront') {
				$('.mo_text').html(+Math.ceil(walkDetail.dis / 50) + '米后 左前方直行')
				if (Math.ceil(walkDetail.dis / 50) > 0) {
					$('.mo_pic').css({
						'background': 'url("./images/zuoqian.png") center center no-repeat',
						'backgroundSize': 'contain'
					})
				}

				if (walkDetail.dis > 0 && walkDetail.dis < 150) {
					$('.mo_text').html('左前方前进')
					if (object.flagAudio) {
						audioAutoPlay("mo_yuyin", "左前方前进", "5")
					}
				}
			} else if (walkDetail.turn == 'RightFront') {
				$('.mo_text').html(+Math.ceil(walkDetail.dis / 50) + '米后 右前方直行')
				if (Math.ceil(walkDetail.dis / 50) > 0) {
					$('.mo_pic').css({
						'background': 'url("./images/youqian.png") center center no-repeat',
						'backgroundSize': 'contain'
					})
				}

				if (walkDetail.dis > 0 && walkDetail.dis < 120) {
					$('.mo_text').html('右前方前进')
					if (object.flagAudio) {
						audioAutoPlay("mo_yuyin", "右前方前进", "5")
					}
				}
			} else {
				$('.mo_text').html(+Math.ceil(walkDetail.dis / 50) + '米后 到达终点')
				object.audioEnd = true;
				$('.mo_pic').css({
					'background': 'url("./images/zhixing.png") center center no-repeat',
					'backgroundSize': 'contain'
				})
				if (walkDetail.dis == 0 && walkDetail.turn == "end") {
					if (object.flagAudio) {
						audioAutoPlay("mo_yuyin", "已到达目的地附近，感谢使用创互地图", "5")
					}
					clearInterval(object.timers)
					$('.scale').hide()
					$(".mo_end_time").html(i)
					$('.mo_distance').html(Math.ceil(realDiss / 50))
					setTimeout(function()  {
						$('.mo_daohang,.mo_tishi').slideUp('fast');
						$(".mo_end").fadeIn(500);
						$(".compass").css("top", "1.8rem")
					}, 1000);
				} else if (walkDetail.dis == 0 && walkDetail.turn == "carport") {
					if (object.flagAudio) {
						audioAutoPlay("mo_yuyin", "已到达目的地附近，感谢使用创互地图", "5")
					}
					clearInterval(object.timers)
					$('.scale').hide()
					$(".mo_end_time").html(i)
					$('.mo_distance').html(Math.ceil(realDiss / 50))
					setTimeout(function() {
						$('.mo_daohang,.mo_tishi').slideUp('fast');
						$(".mo_end").fadeIn(500);
						$(".compass").css("top", "1.8rem")
					}, 1000);
				}
			}
		} else {
			var value
			if (walkDetail.pass == 'Lifts') {
				value = '乘电梯到达' + walkDetail.nextFloorName + '楼'
			} else {
				value = '乘手扶梯到达' + walkDetail.nextFloorName + '楼'
			}
			$('.mo_text').html(value)
			if (object.flagAudio) {
				audioAutoPlay("mo_yuyin", value, "5")
			}
		}
	});
}

function mo_goOn() {
	if (isPause == true) {
		self.map.toggleSimulate(true)
		isPause = false;
	}
	$(".mo_center").html("正在导航")
	$(".scale").hide()
	$('.bg_gSearch').hide()
	$('.nav_qyfg').hide()
}

function moClose() {
	$("#startPoint").val('')
	$("#endPoint").val('')
	object.startP = ""
	object.endP = ""
	$('.mo_daohang,.mo_tishi').slideUp('fast');
	$('.looking,.changeF').css({
		'display': 'block'
	});
	clearInterval(object.navigationInterval);
	$(".compass").css("top", "1.80rem")
	$('#loadings,.gSearch').css('display', 'none');
	$('.bg_gSearch').show()
	$('.nav_qyfg').show()
	$('.operation').show();
	$('.changeF,.looking').css('display', 'block');
	self.map.showFloors([object.floorid])
	self.map.areaClickEmbed = true;
	object.order = object.floorData.length - object.flooridOrder[object.flooridFloors[object.floorid]]
	goback()
}

function yuyin(span) {
	if (object.flagAudio) {
		$(span).css({
			'background': "url('./images/shengyinx.png') center center no-repeat",
			'backgroundSize': 'contain'
		});
		object.flagAudio = !object.flagAudio;
	} else {
		$(span).css({
			'background': "url('./images/shengyin.png') center center no-repeat",
			'backgroundSize': 'contain'

		});
		object.flagAudio = !object.flagAudio;
	}
}



$(".sharedbtn").click(function () {
	$(".sharemask").show();
})
$(".sharemask").click(function () {
	$(".sharemask").hide();
})


function GetQueryString(name) {
	var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
	var r = window.location.search.substr(1).match(reg);
	if (r != null) return unescape(r[2]);
	return null;
}

function replaceArg(url, arg, arg_val) {
	var pattern = arg + '=([^&]*)';
	var replaceText = arg + '=' + arg_val;
	if (url.match(pattern)) {
		var tmp = '/(' + arg + '=)([^&]*)/gi';
		tmp = url.replace(eval(tmp), replaceText);
		return tmp;
	} else {
		if (url.match('[\?]')) {
			return url + '&' + replaceText;
		} else {
			return url + '?' + replaceText;
		}
	}
	return url + '\n' + arg + '\n' + arg_val;
}

function replaceUrl($url) {
	var url = $url
	if (url.indexOf('?') == -1) {
		if (object.floorid) {
			url = url + '?floorid=' + object.floorid;
		}
		if (object.mark) {
			url = url + '&mark=' + object.mark
		}
		if (object.pointmove != {}) {
			url = url + '&pointmove=' + JSON.stringify(object.pointmove)
		}

	} else {
		if (object.floorid) {
			url = replaceArg(url, 'floorid', object.floorid);
		}
		if (object.mark) {
			url = replaceArg(url, 'mark', object.mark);
		}
		if (object.pointmove != {}) {
			url = replaceArg(url, 'pointmove', JSON.stringify(object.pointmove))
		}
	}
	return url
}



function aaa(server, args, callBackFunc) {
	var xhr = $.ajax({
		type: "GET",
		url: server,
		data: args,
		dataType: "JSONP",
		timeout: 2000,
		success: function (data) {
			callBackFunc(data);
		},
		error: function (e) {
		},
		complete: function (XMLHttpRequest, status) {
			if (status == 'timeout') {
				xhr.abort();
				$('.waiting').html('定位超时，请检查网络连接');
				$('.looking').css('display', 'block').html('正在查看 ' + object.flooridFloors[object.floorid] + '');
				$('#loadings').css('display', 'none');
				clearInterval(object.timer)
				setTimeout(function () {
					$('.waiting').fadeOut(3000)
				}, 3000)
			}
		}

	});

}


function convertCoords(params, wifiArea) {
	var p = {};
	p.x = wifiArea.width / wifiArea.tx * params.x + wifiArea.left - GIM.OFFSET;
	p.y = -(wifiArea.height / wifiArea.ty * params.y + wifiArea.top) + GIM.OFFSET;
	return p;

}

$(function () {
	$(".taptap").on("click", function () {
		var index = $(this).index();
		$(this).addClass("taptaptap");
		$(this).siblings().removeClass("taptaptap");
		if (index == 0) {
			$(".mo_end_textaabb").val("体验流畅")
		} else if (index == 1) {
			$(".mo_end_textaabb").val("")
			$(".mo_end_textaabb").val("贴心提示")
		} else if (index == 2) {
			$(".mo_end_textaabb").val("")
			$(".mo_end_textaabb").val("定位不准")
		} else if (index == 3) {
			$(".mo_end_textaabb").val("")
			$(".mo_end_textaabb").val("信息有误")
		}
	})
})

function moEndClose() {
	object.zoomLevel = 1
	$(".compass").css("top", "1.8rem")
	$(".mo_end").css("display", "none")
	$(".changeF").css({
		"display": "block",
		"bottom": "0.9375rem"
	})
	object.startP = object.endP = null;
	self.map.showFloors([object.moFloorid.start]);
	object.order = object.floorData.length - object.flooridOrder[object.flooridFloors[object.moFloorid.start]]
	$(".message,.gSearch,.scale").show();
	$('#endPoint,#startPoint').val('');
	$('.scale').css('bottom', '.6rem');
	$(".compass").css("top", "1.8rem")
	self.map.cleanSelectUnit3D()
	$('.taptaptap').removeClass('taptaptap')
	$('.starability-basic input').prop('checked', false)
	document.querySelector('.mo_end_textaabb').placeholder = '其他想说的'
	$('.mo_end_textaabb').val('')
	self.map.setPolarAngle(0);
	self.map.setAzimuthalAngle(90);
	self.map.move2Point({
		x: 200,
		y: 0
	});
	self.map.zoomLevel(object.zoomLevel);
	self.map.areaClickEmbed = true;
	document.querySelector('#text').placeholder = '商铺任！你！搜！';
	$('#text').val('');
	if (config.flagMark) {
		$('.mark').show();
	} else {
		$('.mark').hide();
	};
	goback()

}


function moEndSend() {
	object.zoomLevel = 1
	$(".mo_end").css("display", "none")
	$(".thanks_tips").fadeIn()
	setTimeout(function() {
		$(".thanks_tips").fadeOut()
	}, 1200);
	$(".compass").css("top", "1.8rem")
	$(".changeF").css({
		"display": "block",
		"bottom": "0.9375rem"
	})
	object.startP = object.endP = null;
	self.map.showFloors([object.moFloorid.start]);
	object.order = object.floorData.length - object.flooridOrder[object.flooridFloors[object.moFloorid.start]]
	$('#endPoint,#startPoint').val('');
	$(".message,.gSearch,.scale").show();
	$('.scale').css('bottom', '.6rem');
	$(".compass").css("top", "1.8rem")
	if (config.flagMark) {
		$('.mark').show();
	} else {
		$('.mark').hide();
	};
	self.map.cleanSelectUnit3D()
	$('.taptaptap').removeClass('taptaptap')
	$('.starability-basic input').prop('checked', false)
	document.querySelector('.mo_end_textaabb').placeholder = '其他想说的'
	$('.mo_end_textaabb').val('')
	clearInterval(object.navigationInterval);
	self.map.setPolarAngle(0);
	self.map.setAzimuthalAngle(90);
	self.map.move2Point({
		x: 200,
		y: 0
	});
	self.map.areaClickEmbed = true;
	self.map.zoomLevel(object.zoomLevel);
	document.querySelector('#text').placeholder = '商铺任！你！搜！';
	$('#text').val('');

	$('.nav_qyfg').show()
	$('.bg_gSearch').show()
	goback()
}

function searchPathFailClose() {
	$(".searchPathFailBox").hide()
}

function setPoint(RoomNo, type) {
	if (type == 1) {
		self.map.focusToShopByNo(RoomNo, true);
		object.isEnd = true
	} else if (type == 2) {
		self.map.selectByAreaID(RoomNo, true);
		object.isEnd = true
	}
	$('#loadings').show()
	setTimeout(function () {
		$('#loadings,.luxian,.nav_gn,.nav_yg,.nav_qj,.nav_zz').hide()
		if (object.isStart == true) {
			setStart()
		} else if (object.isEnd == true) {
			setEnd()
		}
	}, 2000)
	self.map.zoomLevel(20)
	setTimeout(function () {
		$('.nav_fj').hide()
		object.isEnd = false
		object.isStart = false
	}, 2000)
}


function goSearch() {
	$('.main').css({
		'display': 'none'
	});

	$('.nav_qyfg').show()
	document.querySelector('#text').placeholder = ' '
	document.querySelector('#text').value = ''
	getshops('A946DBEE-51C9-4A97-A0BB-42EF31B3E029', 'SC', 'getArea', "{'key':'123'}")
	$(".floorToggleUl button").removeClass().addClass(".floorToggleUl_List")
}

function searchBack() {
	$('#text').val('')
	$('.nav_fj,.nav_yg').hide()
	$('.operation').css('display') == 'block' ? $('.gSearch').hide() : $('.gSearch').show()
	$('.operation').css('display') == 'block' ? $('#nav_qyfg').hide() : $('#nav_qyfg').show()
	$('.swiper-container1,.scale,.floorToggleUl,.floorToggle').css('bottom', '.4rem');
	self.map.cleanSelectUnit3D()
	goback()

}

function spanBtn() {
    $('.spanSearch').on('click', function() {
        var name = $(this).html().toLowerCase()
        document.querySelector('#text').value = name;
        guolu(name)
    })

}

function hisLiBtn(li) {
    var name = $(li).html().toLowerCase()
    document.querySelector('#text').value = name;
    guolu(name)
}

function historyBtn() {
    $('.his_list ul li ').on('click', function() {
        var name = $(this).html().toLowerCase()
        guolu(name)
    })
}

function clearHistory() {
    $('.his_list ul li').remove()
}

function setHistory(str) {
    var storage = window.localStorage;
    var history = storage.getItem("history");
    if (history) {
        history += ','
        history += str
        storage.setItem("history", history);
    } else {
        storage.setItem("history", str);
    }


}

function getHistory() {
    var storage = window.localStorage;
    var history = storage.getItem("history");
    var arr = history.split(",");
}


function spanBtn() {
	$('.spanSearch').on('click', function () {
		var name = $(this).html().toLowerCase()
		document.querySelector('#text').value = name;
		guolu(name)
	})

}

function hisLiBtn(li) {
	var name = $(li).html().toLowerCase()
	document.querySelector('#text').value = name;
	guolu(name)
}

function historyBtn() {
	$('.his_list ul li ').on('click', function () {
		var name = $(this).html().toLowerCase()
		guolu(name)
	})
}

function clearHistory() {
	$('.his_list ul li').remove()
}

function setHistory(str) {
	var storage = window.localStorage;
	var history = storage.getItem("history");
	if (history) {
		history += ','
		history += str
		storage.setItem("history", history);
	} else {
		storage.setItem("history", str);
	}


}

function getHistory() {
	var storage = window.localStorage;
	var history = storage.getItem("history");
	var arr = history.split(",");
}